Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add method Validate for RouteService #368

Merged
merged 5 commits into from
Aug 29, 2023
Merged

Conversation

programmer04
Copy link
Member

@programmer04 programmer04 commented Aug 25, 2023

What this PR does / why we need it:

Gateway offers API for validating routes - /schemas/routes/validate. This PR extends RouteService with the method Validate (that calls aforementioned endpoint) and prepares the release of the new version v0.47.0.

Which issue this PR fixes:

Prerequisite to implement Kong/kubernetes-ingress-controller#4557.

Special notes for your reviewer:

Hence this method will be used to validate expressions routes, extend tests with this configuration, and introduce a helper to skip tests when it is not applicable (also a small refactor to avoid unnecessary duplication). Extend the tests matrix with such a configuration, tests run quickly, but on the other hand, need a lot of runners - using exclude in workflow helps a lot. The number of checks increased from 45 to 66 (added Kong 3.4 to the matrix too).

Change in kong/vault_service_test.go is needed, because more values are in this map (for Kong 3.4) and others are rather random/irrelevant nad the region is presented for older versions, thus it doesn't break anything.

To consider: creating an issue for covering with tests routes when expressions router is enabled.

@programmer04 programmer04 added the enhancement New feature or request label Aug 25, 2023
@programmer04 programmer04 self-assigned this Aug 25, 2023
@programmer04 programmer04 requested a review from a team as a code owner August 25, 2023 15:12
@programmer04 programmer04 requested a review from a team August 25, 2023 15:12
@programmer04 programmer04 enabled auto-merge (squash) August 25, 2023 15:12
@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2023

Codecov Report

Patch coverage: 70.27% and project coverage change: +0.50% 🎉

Comparison is base (2049fa9) 52.56% compared to head (001cd2f) 53.06%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #368      +/-   ##
==========================================
+ Coverage   52.56%   53.06%   +0.50%     
==========================================
  Files          69       69              
  Lines        5175     5201      +26     
==========================================
+ Hits         2720     2760      +40     
+ Misses       1877     1857      -20     
- Partials      578      584       +6     
Flag Coverage Δ
2.1 33.10% <43.24%> (-3.22%) ⬇️
2.2 44.58% <43.24%> (-3.17%) ⬇️
2.3 45.29% <43.24%> (-3.17%) ⬇️
2.4 45.37% <43.24%> (-3.17%) ⬇️
2.5 45.37% <43.24%> (-3.17%) ⬇️
2.6 45.37% <43.24%> (-3.17%) ⬇️
2.7 46.87% <43.24%> (-3.18%) ⬇️
2.8 46.87% <43.24%> (-3.18%) ⬇️
3.0 50.56% <59.45%> (+0.07%) ⬆️
3.1 52.02% <59.45%> (+0.06%) ⬆️
3.2 52.08% <59.45%> (+0.06%) ⬆️
3.3 52.08% <59.45%> (+0.06%) ⬆️
3.4 52.41% <59.45%> (?)
community 38.24% <70.27%> (+0.25%) ⬆️
enterprise 51.74% <70.27%> (+0.51%) ⬆️
enterprise-nightly 50.75% <59.45%> (+0.07%) ⬆️
integration 53.06% <70.27%> (+0.50%) ⬆️
nightly 37.58% <59.45%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
kong/route_service.go 55.55% <50.00%> (-0.55%) ⬇️
kong/test_utils.go 59.70% <80.00%> (+7.20%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@programmer04 programmer04 force-pushed the add-routes-validator branch 8 times, most recently from fd30c6a to 5370965 Compare August 25, 2023 17:42
Copy link
Contributor

@rainest rainest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to test this in isolation? It seems a bit silly to run all tests against both flavors when it only matters for the one in practice.

@programmer04
Copy link
Member Author

It's negligible that other test runs because the whole test suite (make test) takes ~10s. The problem (and bottleneck) is that router configuration can be only provided during the provisioning of the Kong Gateway and for every version and deployment type postgres, dbless, and enterprise new instance of Kong Gateway is spun up (instance of GitHub check). So even if I'd like to run only one test still the whole env has to be provisioned - an instance of GitHub check. Maybe it's worth improving it somehow, but I think it should create a separate issue for it

@programmer04 programmer04 requested a review from rainest August 26, 2023 18:44
@czeslavo
Copy link
Contributor

Is /schemas/routes/validate expected to work only for expression routes? As I understand Kong/kubernetes-ingress-controller#4557, we want to make sure the path that a user specifies in an Ingress/HTTPRoute is going to be parsed into a valid Kong Route, despite the router used.

kong/vault_service_test.go Outdated Show resolved Hide resolved
.github/workflows/integration-test.yaml Outdated Show resolved Hide resolved
.github/workflows/integration-test-enterprise.yaml Outdated Show resolved Hide resolved
Co-authored-by: Grzegorz Burzyński <[email protected]>
@programmer04 programmer04 requested a review from czeslavo August 28, 2023 12:34
@programmer04 programmer04 requested a review from czeslavo August 28, 2023 18:26
@programmer04 programmer04 merged commit 88b24ff into main Aug 29, 2023
66 checks passed
@programmer04 programmer04 deleted the add-routes-validator branch August 29, 2023 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants